package com.kotlin.flong.base

/*
 *异常
 */
fun main(args: Array<String>) {

    //exception1()
    println(exception2())

}

fun exception1() {
    var a = 1
    var b = 0

    try {
        a / b
    } catch (e: Exception) {
        println("异常信息" + e.getLocalizedMessage())
    } finally {
    }
}

//异常给默认值0
fun exception2(): Int {
    var a = 1
    var b = 0

    try {
        a / b
    } catch (e: Exception) {
        println("异常信息" + e.getLocalizedMessage())
    } finally {
        return 0
    }
}

